-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #729
base: master
Are you sure you want to change the base?
Solution #729
Conversation
app/main.py
Outdated
class Carnivore(Animal): | ||
|
||
def bite(self, animal: Animal) -> None: | ||
if isinstance(animal, Carnivore): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/main.py
Outdated
self.alive.append(self) | ||
|
||
def __repr__(self) -> str: | ||
return (f"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several changes were requested.
app/main.py
Outdated
self.name = name | ||
self.health = health | ||
self.hidden = hidden | ||
self.alive.append(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alive
is not an instance attribute, it is a class attribute. Call it from Animal
here.
app/main.py
Outdated
class Carnivore(Animal): | ||
|
||
def bite(self, animal: Animal) -> None: | ||
if not isinstance(animal, Carnivore): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make check that the instance is exactly Herbivore
, your code may be corrupted in case there would be other animals added later.
…stance in bite() [class Carnivore]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
No description provided.